package com.pocketsweet.ui.uilib;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.TextView;

import com.pocketsweet.R;

public class RandomColorWillingTag extends TextView {
	public RandomColorWillingTag(Context context) {
		super(context);
		// 初始化
		init(context);
	}

	public RandomColorWillingTag(Context context, AttributeSet attrs) {
		super(context, attrs);

		// 初始化
		init(context);
	}

	private void init(Context context) {
		int[] drawables = { R.drawable.shape_rectangle_green,
				R.drawable.shape_rectangle_orange,
				R.drawable.shape_rectangle_red_recommend,
				R.drawable.shape_rectangle_yeallow,
				R.drawable.shape_rectangle_bule_empty };
		int[] colors = { R.color.text_green,
				R.color.orange,
				R.color.text_gender_female,
				R.color.text_yellow,
				R.color.text_blue };
		
		int random = (int) (Math.random() * 10) % 5;// 0~5随机数
		int textcolor = getResources().getColor(colors[random]);
		this.setBackgroundResource(drawables[random]);
		this.setTextColor(textcolor);
		FlowLayout.LayoutParams params = new FlowLayout.LayoutParams(
				FlowLayout.LayoutParams.WRAP_CONTENT,
				FlowLayout.LayoutParams.WRAP_CONTENT);
		params.rightMargin = 10;
		params.bottomMargin = 10;
		params.topMargin = 10;
		params.leftMargin = 10;
		this.setLayoutParams(params);
	}

	@SuppressWarnings("unused")
	public void setName(String value) {
		this.setText(value);
	}
}
